//
//  UIView+IBExtension.swift
//  weibohhhh
//
//  Created by fersh on 16/1/3.
//  Copyright © 2016年 fersh. All rights reserved.
//

import UIKit
/**
 *  在右视图中为UIView动态添加属性
 */
extension UIView {
    @IBInspectable var cornerRadius: CGFloat {
        get{
            
            return layer.cornerRadius
        }
        set{
            
            layer.cornerRadius = newValue
            layer.masksToBounds = (newValue > 0)
        }
    }
    @IBInspectable var borderWidth: CGFloat {
        get{
            
            return layer.borderWidth
        }
        set{
            
            layer.borderWidth = newValue
        }
    }
    
    @IBInspectable var  borderColor: UIColor? {
        get{
            
            guard let c = layer.borderColor else {
                return nil
            }
            
            return UIColor(CGColor: c)
            
        }
        set{
            
            layer.borderColor = newValue?.CGColor
        }
        
        
    }
    
}
extension UIButton {
    convenience init(titelColor: UIColor?, fontSize:CGFloat) {
        self.init()
        
        self.setTitleColor(titelColor, forState: UIControlState.Normal)
        self.titleLabel?.font = UIFont.systemFontOfSize(fontSize)
    }
    
}
extension UILabel {
    convenience init(titelColor: UIColor?, fontSize:CGFloat) {
        self.init()
        
        self.textColor = titelColor
        self.font = UIFont.systemFontOfSize(fontSize)
    }
    
}
